home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
EDITOR
/
AMAC44.ARJ
/
SRCH32.QM
< prev
next >
Wrap
Text File
|
1992-06-22
|
26KB
|
576 lines
* SRCH32.QM
* Macros To Search/Replace In Text And ZIP Files
* Written by Tom Hogshead
* 6/1/92
* Key Subfile Description
* ==== =============== ================================================
* FROM COMMAND LINE ONLY...
* @0 {e:\up\SR} Search/Replace with SR.BAT and SZR.BAT (zip's) |chg
* @5 {e:\up\SRQ} Search/Replace with SRQ.BAT, Quit After Rplcmnt. |chg
* @7 {e:\up\SRL} Search Only with SRL.BAT and SZ.ZIP (zip's) |chg
* @6 {e:\up\SM} Search Only with SM.BAT (Maxfind)
*
* WHILE EDITING...
* @1 Make Filelist Containing Search Text
* @2 Load Filelist Containing Search Text
* @3 Search/Replace Across All Files in Ring
* @f1 Find All Search Text In Current File, Use FGREP
* @f2 Find All Search Text In Current File, Use Dos FIND
* @f3 View Another Occurrence of Srch Text Aftr @f1/f2 |chg
* f4 RepeatFind
* f5 PrevFile
* f6 NextFile
* @h Locate Index Item In Current File Below
*
* Index Use, How to locate macro or item below from Index using @h
* Description, Search/Replace Macros
* Startup, What's Required
* Environment Variables
* Required Program Files
* Macros
* Other Macros
* CAUTION <<<<<<<<<<<<<<<<<<< IMPORTANT
* Version History
*
*-- eoi
* Confirms Saves Must Be
* Replace- Loaded First
* Key Run While ment? Files? Macro? [1] Comments
* ── ───────── ──────── ────── ────── ─── ───────────────────
* @0 cmnd line no yes yes f s/r w/SR.bat/SZR.BAT
* @5 cmnd line no yes/quit yes f s/r w/SRQ.bat
* @6 cmnd line srch only n/a yes m s/o w/SM.BAT
* @7 cmnd line srch only n/a yes f s/o w/SRL.BAT/SZ.BAT
* @1┐ editing n/a n/a no f makes FileList only
* @2┤ editing n/a n/a no f loads files only
* @3┘ editing no rpl only no f s/r loaded files
* @f1 editing srch only no no f s/o current file
* @f2 editing srch only no no f s/o current file
* @f3 editing n/a no no View another occurrence
* ----------------------------
* [1] Uses: m- MAXFIND f - FGREP.COM
* (INDEX) USE; To locate a macro or item in this file, press @h, place
* the cursor line on the desired item in the Index above, and press
* <enter>. See BOOKxx.QM for more details.
* (DESCRIPTION): (SRCH32) are QEdit macros to search/replace and search
* only files containing search text from a file pattern or a FileList
* of file patterns to search using FGREP.COM and MAXFIND. Only files
* containing the search text are loaded automatically, and then the
* desired search/replace is performed. Search/replace may be done from
* the command line and while editing files. Search or search/replace
* may be also performed on ZIP files without manually unzipping and
* rezipping.
* In addition to SR, SRL, and SRQ batch files, two additional batch
* files are provided to search and replace files within ZIP's. SZ.BAT
* and SZR.BAT are batch files using FGREP.COM to search and
* search/replace text within ZIP's without having to manually unzip,
* search, replace, and then rezip. For example, at the command line:
* SZR fff FFF TEST <enter>
* finds all occurrences of "fff" in files within TEST.ZIP and replaces
* it with "FFF". Files containing the search text are loaded after
* replacement so each replacement can be viewed before re-zip. The
* user is given the option of updating each ZIP on a file by file basis
* before re-zipping.
* Batch file SM.BAT is also provided to search text files with MAXFIND.
* SM.QM are QEdit macros to use with SM.BAT for searching files
* containing a search string using MaxFind. Files are searched, found,
* and loaded for editing or viewing. The search string, file names, and
* other input or search options may be specified at the command line or
* entered at the option query prompt. "Fuzzy", "and/or", and "sliding
* window" text searches can be done.
* If you wish to do 'case sensitive' search/replace, modify SR.BAT as
* follows:
* FGREP.COM -flc /%S~~%/ %file% >c:\$.ql
* ^
* (STARTUP): To BEGIN, just type "START SRCH" <Enter>. All pertinent
* files will be loaded in the "Ring" for viewing, and SRCH32.MAC is
* read.
* To perform a search/replace from the command line, type SR, and
* answer the prompts for search and replace text. To perform a SEARCH
* ONLY from the command line, type SRL, and answer the prompts for
* search text. All searches with these macros and batch files are
* Case insensitive. To perform a case sensitive search, change "GIN"
* to "GN"in the macros and "-f" to "-fc" in the batch files.
* Search and replacement text must be single words when entered at teh
* command line. Multiple word search/replacement text can only be
* entered when answering search and replacement query prompts, not from
* the command line.
* Replacing c:\ with your ram disk will spped things up.
* (ENVIRONMENT) VARIABLES
* -------------------------
* All search and search/replace batch files use environment variables.
* Some environment variables can be set to facilitate use of these
* batch files, however setting any environment variable is optional. If
* any or all of the following environment variable are *not* set (ie
* "SET [name]= " the user will be prompted for the required inputs, or
* values can be specified at the command line as described in each
* batch file.
* a) "SET OPT=off" will bypass the option query prompt in SRL.BAT and
* SM.BAT, and bypass the File Name query prompt in SR.BAT and
* SRQ.BAT.
* b) "SET OPT= " will *not* bypass the option query prompt in SRL.BAT
* and SM.BAT, and will *not* bypass the File Name query prompt in
* SR.BAT and SRQ.BAT.
* c) "SET FILELIST=srch-fg.lst" searches with standard file list
* srch-fg.lst in SR.BAT, SRL.BAT and SRQ.BAT. SM.BAT uses the
* program MAXFIND which cannot search from filelists.
* d) "SET FILELIST=c:\srch-fg.lst" searches with standard file list
* c:\srch-fg.lst in SR.BAT, SRL.BAT and SRQ.BAT.
* e) "SET FILELIST=sm.lst" searches with standard file list sm.lst for
* testing SR.BAT, SRL.BAT and SRQ.BAT. SM.LST is provided in
* AMACxx.ZIP. SM.LST is just one line "*.tst" to search SM.TST,
* and any other files with extension .tst.
* f) "SET FILELIST= " will prompt for file name(s) or an @filelist at
* the File Name query prompt. The batch files are written to use
* file list SM.LST if nothing is entered at the File Name query
* prompt.
* The macros used with these batch files must either be located in the
* current directory from which we are searching, or the location of
* these macros must be specified with the environment variable SRMAC as
* follows:
* g) "SET SRMAC= " means macro files are located in current directory
* from which we are searching.
* h) "SET SRMAC=c:\" means macro files are located in c:\ directory.
* c:\ may be any drive:\path\ terminating with a \.
* By default, SZ.BAT and SZR.BAT create, and delete afterwards, a
* temporary directory c:\$zip$ into which the ZIP file is un-zipped. It
* is preferable to use a ram drive for speed. An alternative temporary
* directory can be used by setting the environment variable SZTEMP as
* follows:
* i) "SET SZTEMP= " uses default directory c:\$zip$ for the temporary
* directory.
* j) "SET SZTEMP=e:\name" uses directory e:\name (no trailing \) for
* the temporary directory.
* Here's contenets of file SRCH-FG.LST included:
* *.qm
* *.ql
* *.inf
* *.bat
* *.lst
* *.me
* *.doc
* *.syn
* *.tst
* *.new
* *.lgo
* e:\syn\sa.syn
* e:\nk\nk1.key
* The SA.SYN entry is my PCED synonym file. NK1.KEY is my NewKey macro
* file. Batch files have more information and instructions.
* The following temporary environment variables are set during batch
* file operation and need not be set by the user:
* S~~ search text
* R~~ replacement text
* file File Name or file list specified at query prompt or
* at the command line.
* All environment variables remain as set during operation so they may
* be viewed with SET afterwards.
* ********* (CAUTION) ***********
* *************************************************************************
* * Alt_0/5/6/7 set and use the Dos environment variables S~~ and R~~. *
* * The letters "S~~" and "R~~" must NOT occur in any other Dos *
* * environment variable name or value. If any files being searched have *
* * attribute set Read Only, macros will stop when they try to save a *
* * Read Only file after replacements have been made. *
* *************************************************************************
* You must have enough environment space to store both the search and
* replacement text. I suggest at least 100 bytes.
* QEdit must be named Q.EXE. Insert should be ON.
* For (other) macros, see ALLMACRO.INF.
* These macros require "QEdit and QMAC v2.1, February, 1990" or later.
* Some macros require QEdit v2.15.
* (REQUIRED) PROGRAM FILES
* -------------------------
* You──MUST──have the executable program files in AMAC-PRG.ZIP to run
* some of these macros. AMAC-PRG.ZIP can be found on the following BBS's:
*
* SemWare
* Exec-PC
* It can NOT be found on CompuServe since many of the programs are
* Copyrighted. All program files are ShareWare, and inclusion in
* AMAC-PRG.ZIP is not prohibited in their documentation.
* FGREP.COM.ZIP and INPUT.ZIP are the only files necessary to run
* SR.BAT, SRL.BAT and SRQ.BAT. MAXFND23.COM and INPUT.COM are the only
* files necessary to run SM.BAT. FGREP.COM, DX.EXE, PKZIP.EXE and
* PKUNZIP.EXE are required to run SZ.BAT and SZR.BAT.
* FGREP.COM can be found on Exec-PC as FGREP172.ZIP. INPUT can be
* found on Exec-PC as INPUT.ZIP. MAXFIND v2.3 can be found on
* CompuServe IBMSYS Lib 3 as MAXFND.ZIP and on EXec-PC as MAXFND23.ZIP
* See SR.BAT and SZR.BAT for files required to search/replace within
* Zip's.
* AMAC-PRG.ZIP contains:
* ----------------------
* Name Length Method SF Size now Mod Date
* ============ ======== ======== ==== ======== =========
* INPUT.ZIP 3097 Stored 0 3097 07 May 86
* MAXFND23.ZIP 24247 Stored 0 24247 26 Apr 90
* RJ.ZIP 9965 Stored 0 9965 01 Dec 90
* FGREP172.ZIP 12513 Stored 0 12513 19 May 90
* DX211.ZIP 100895 Stored 0 100895 17 Mar 89
* AMAC-PRG.INF 3138 Imploded 67 1014 23 Apr 91
* ============ ======== ======== ==== ======== =========
* *total 6 153855 ZIP 1.10 0% 152329 23 Apr 91
* These files are probably on many other BBS's also. I thank the
* authors for these excellent programs.
* (Macros)
* M A C R O S
* ----------------------------------------------------------------------
* @(1) Makes Filelist Of Files Containing Search Text
* ----------------------------------------------------------------------
@1 macrobegin
onewindow * For sort *|
dos 'fgrep -f0 /' * Make FileList
pause * Pause for search text
'/>c:! @srch-fg.lst'* Fgrep input
pause * Pause to change filelist/files *|
return return
editfile
"c:!" return quit
editfile return * Edit FileList
begfile markcolumn * Mark begfile c:!
endfile begline * Mark endfile col 1
wordright wordright * Get to file name
cursorleft * Move off file name
deleteblock * Delete file name
savefile * Save FileList
begfile markcolumn * Mark begfile c:!
endfile * Get to end
gotocolumn "12" return * Get all file names in block
sort * Sort FileList
killfile * Kill c:!
begfile unmarkblock
*
* 99 bytes Tue 07-02-1991 17:56:32 (TH @1)
* 101 bytes Thu 04-16-1992 09:58:07 (TH @1, pause to change input)
*
* ----------------------------------------------------------------------
* @(2) Loads Filelist Of Files Containing Search Text
* ----------------------------------------------------------------------
* Written by Kyle Watkins, SemWare.
@2 MacroBegin
EndFile BegLine * Start at last line
REPEAT:
UnmarkBlock
MarkLine Copy * Grab this name
EditFile * Get ready to load
CurrentFilename " " * To force return *here*
Paste Return * Paste file name & do it!
CursorUp * More lines above?
JTrue REPEAT * If yes, repeat.
*
* 19 bytes Mon 09-03-1990 00:56:04
*
* ------------------------------------------------------------------------
* @(3) Search and Replace Across All Files In Ring
* ------------------------------------------------------------------------
* This macro will do a search and replace of all files in the ring. If
* no replacement is made, that file is 'quit'. If any replacement is
* are made, that file is saved and remains loaded. Replacement is case
* insensitive. This macro requires QEdit v2.15.
* User is prompted for search and replace text. The replacements are
* then made, and the macro ends when all replacements have been made
* with the cursor in the starting file. If the macro does not end with
* the cursor in the starting file, this means the file the macro ends
* in had the cursor in column 2 when the macro was invoked, which is
* the 'position marker' used to end the macro after cycling through all
* files in the ring, and you should continue invoking the macro until
* the you end in the starting file. The starting file will not be
* quit from the ring if no replacements are made.
* This macro is based on a macro written by Kyle Watkins on SemWare BBS
* Conference 0, Message #9940, "Once Around the File-Ring", 9/14/90. A
* copy of that message is in Amac42e.zip and prior versions of Amac.
* Prior versions of @3 used the Nul file as a position marker. This
* version uses the starting file as 'position marker' putting the
* cursor in column 2 to trigger the macro to end after cycling through
* all files in the ring.
@3 macrobegin
begline cursorright * Put cursor in col 2 *|
findreplace
pause return * User input of Find Item
pause return * User input of Replace Item
"GIN" return * Do all loaded files no prompt
* pause return * Use to select options
jtrue SAVE * If changes, save file we started in *|
LOOP:
setscreenon setscreenoff * Remove if not using QEdit v2.15
nextfile * Move to next files in ring
cursorleft jfalse REPLACE * If we can't move left, begin replacement
cursorleft jfalse END * If we still can't move left, we're in
* file we started in, end macro
REPLACE:
pageup jtrue REPLACE * Must be at tof for repeatfind w/GIN *|
repeatfind * Do the FindReplace
jtrue SAVE * If changes are made save file
quit * Quit file w/no replacements
jump LOOP
SAVE:
savefile * Save file with changes
jump LOOP
END:
*
* 62 bytes Sat 09-15-1990 11:17:57 (K. Watkins version)
* 41 bytes Sun 09-30-1990 20:32:55 (this version)
* 45 bytes Tue 08-06-1991 22:30:19 (TH @8, replaced '!' with 'NUL')
* 50 bytes Tue 08-06-1991 22:37:23 (TH @8, set FindReplace option 'GIN')
* 50 bytes Wed 04-22-1992 00:10:05 (TH @3, changed key)
* 48 bytes Fri 05-22-1992 12:17:29 (TH @3, added setscreenoff|on,
* removed Nul file)
*
* ----------------------------------------------------------------------
* @(5) Search/Replace From Command Line, Quit Each File After Rplcmnt.
* ----------------------------------------------------------------------
* See SRQ.QM for this macro.
*
* ----------------------------------------------------------------------
* @(6) - Srch Only From Command Line, Loads Files w/SM.BAT, No Replace
* -------------------- uses MaxFind mf.exe -----------------------------
* See SM.QM for @6.
*
* ----------------------------------------------------------------------
* @(7) -Start Up Macro, Loads Only Found Files, No Replacement
* ----------------------------------------------------------------------
* See SRL.QM for @7.
*
* ----------------------------------------------------------------------
* @(0) Macro For Search/Replace From Command Line With SR.BAT
* ----------------------------------------------------------------------
* See SR.QM for @0.
* @f1 and @f2 macros are modifications to macros written by Tim Farley
* in BIGFIND.QM dated 8/21/89 and revised 9/6/89.
*
* ----------------------------------------------------------------------
* @(f1) Find Multiple Search Text In Current File, Uses FGREP.COM
* ----------------------------------------------------------------------
* Find all instances of a given string in current file, let the user
* select one, hit return, and view line containing search string.
* Change "c:" to ramdrive for faster operation.
*
* Uses Chris Dunford's excellent FGREP.COM. Remember search string is
* case insensitive.
@f1 MacroBegin
UnmarkBlock DropAnchor * Mark current file to return to
* later
EditFile
"c:!" Return Quit * Quit temp file if loaded
* Sets EditFile prompt for later
GotoBlockBeg * Return to where we were
UnmarkBlock
DOS 'FGREP -L /' * Prompt for search text
Pause
'/>c:! ' * Echo output to temp file
CurrentFilename Return
Return * Search current file
EditFile Return * Load temp file with found text
Pause * Pause to select line to view
BegLine WordRight MarkWord * Mark found text line number
Copy * Copy line number to scrap
KillFile * Delete temp file from disk
PrevFile * Return to searched file
GotoLine Paste Return * View found text line
MakeCtrOfScreen * Put on screen center
*
* 67 bytes Tue 07-02-1991 17:57:22 (TH ^f1)
* 67 bytes Tue 05-26-1992 10:08:25 (TH @f1, changed key from ^f1)
*
* ----------------------------------------------------------------------
* @(f2) Find Multiple Search Text In Current File, Uses Dos FIND
* ----------------------------------------------------------------------
* Find all instances of a given string in current file, let the user
* select one, hit return, and view line containing search string.
* Change "c:" to ramdrive for faster operation.
*
* Uses Dos FIND. Remember search string is case sensitive.
@f2 MacroBegin
UnmarkBlock DropAnchor * Mark current file to return to
* later
EditFile
"c:!" Return Quit * Quit temp file if loaded
* Sets EditFile prompt for later
GotoBlockBeg * Return to where we were
UnmarkBlock * Unmark
Dos 'FIND /N "' * Prompt for search text
Pause '" '
CurrentFilename * Search current file
'>c:!' Return
Return * Echo output to temp file
EditFile Return * Load temp file with found text
Pause * Pause to select line to view
BegLine
WordRight MarkWord * Mark found text line number
Copy * Copy line number to scrap
KillFile * Delete temp file from disk
PrevFile * Return to searched file
GotoLine Paste Return * View found text line
MakeCtrOfScreen * Put on screen center
*
* 65 bytes Sat 02-16-1991 02:55:59
* 65 bytes Tue 05-26-1992 10:08:57 (TH @f2, changed key from ^f2)
*
* ----------------------------------------------------------------------
* @(f3) View Another Occurrence Of Search Text In Current File
* ----------------------------------------------------------------------
* Position cursor on line to view another occurrence of search text in
* current file, and hit <enter>. Works only after running either
* @f1 or @f2.
@f3 MacroBegin
onewindow * Close all windows
horizontalwindow
editfile escape * For all Qconfig's *|
zoomwindow * Open window full, current file
editfile "c:!" return * Load temp file with found text
begline * Re-position cursor
pause * Pause to select line to view
wordright markword copy * Mark line #, copy to scrap
zoomwindow * Zoom temp file window small
prevwindow * Back to orig file window
begline * Re-position cursor
gotoline paste return * Goto found text line
* pause * Pause to see temp file
zoomwindow * Zoom orig window full
*
* 27 bytes Mon 02-18-1991 00:31:32
* 29 bytes Wed 05-13-1992 12:45:20 (TH ^f3, for all Qconfig's)
* 29 bytes Tue 05-26-1992 10:09:26 (TH @f3, changed key from ^f3)
*
* ----------------------------------------------------------------------
* @(h) Jump From Index Line To (Locate) Macro or Item In Document Below
* ----------------------------------------------------------------------
* Alt_h can be used to quickly jump from Index Line to the desired
* item or macro in the document below:
* 1. Press Alt and h at the same time. Line 1 is marked to
* highlight. Cursor down to desired line in Index.
* 2. Press Enter. The macro then locates and jumps to the item
* selected on the cursor line in the document below.
* See BOOKxx.Qm and JMPPOSxx.QM in AMACxx.ZIP for more discussion about
* using bookmarks and positions markers ( ) to jump to positions in
* files.
@h macrobegin
unmarkblock defaultwordset begfile endpara markline begfile
find "(" return "L" return
jfalse NOMARK
makectrofscreen begfile
unmarkblock markline markline prevposition begline
pause
wordright markword copy endpara
find "(" paste ")" return "I" return
jfalse NOMARK
begline maketopofscreen scrollup
jump END
NOMARK:
begfile
END:
*
* 52 bytes Wed 07-31-1991 14:43:31 (TH @h, @4 in BOOKxx.QM)
* (f4)
f4 RepeatFind
* (f5)
f5 PrevFile
* (f6)
f6 NextFile
* (VERSION) HISTORY
* -------------------
* 3.0b - In AMAC42.ZIP. 3/28/92
* 3.1 - Modified @0/4/7 for QEdit v2.15. 4/15/92
* - Modified @1 to be able to change fgrep inputs. 4/16/92
* - Added onewindow to @1 and @5. 4/21/92
* - Changed some keys. 4/22/92
* - In Amac42e.zip. 4/26/92
* 3.1a - Changed find initialization in sr.qm. 5/12/92
* - Modified ^f3 for all Qconfig's. 5/13/92
* - Moved @a/f and ^a/f to mis001.qm. 5/18/92
* - Removed @4, @8, cursorleft and cursorright. 5/18/92
* - Shortened @3. 5/22/92
* - Modified documentation in SM.QM. 5/22/92
* - Removed f4/f5/f6 from srq.qm. 5/26/92
* (In Amac43.zip)
* 3.2 - Modified SR.QM, SRQ.QM, SR.BAT, SZ.BAT, SRQ.BAT & SZR.BAT 6/1/92
* to enable text to be removed (Replaced with nothing).
* - Shortened SRL.QM. 6/1/92
*
*
*
*
*
*
*
*
*-- eof